<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						
?>
<html>
<head>
	
</head>
<body>				
<form name='assets' method='post' action='/core/assets.php' onsubmit='return checkdata(this)'>
  <table width="100%" border="0">
    <tr>
      <td><a href="assets_form.php">Crear Nueva Instalacion</a></td>
    </tr>
    <tr>
      <td><? 
			
		$sql = "select a.id_asset, a.astatus, a.restrictions,a.astatus, f.name as fac_name, a.name as ass_name,ft.name as ftype_name
					from assets a, `facilities` f, `facility_type` ft 
					where f.id_facility = a.id_facility and
					f.id_ftype = ft.id_ftype
					order by f.name, a.name";
			
		$result = mysql_query($sql);
			
		if($result){
				
			$data ="<table width='100%' border='0'>";
				
			if(mysql_num_rows($result) > 0){
					
				while($row = mysql_fetch_array($result)){
						
					$data .="<tr>
											
						<td align='left' >
							<a href='assets_form.php?id=".$row['id_asset']."'>".$row['ass_name']."</a>
						</td>
						<td align='left' >
							<a href='assets_form.php?id=".$row['id_asset']."'>".  $row['ftype_name'] ." ".$row['fac_name']."</a>
						</td>
						<td align='left' >
							<a href='assets_form.php?id=".$row['id_asset']."'>".$row['astatus']."</a>
						</td>
						<td align='left' >
							<a href='assets_form.php?id=".$row['id_asset']."'>".substr($row['restrictions'],0,100)."</a>
						</td>

										  
						</tr>";
					
				}//while
				
			}//if
				
			else{
					
				$data .= "<tr><td align='center'>No hay assets registrados</td></tr>";			
				
			}
				
			$data .="</table>";
			
		}else{
				
			error_handling($sql,mysql_error());
			
		}
			
		echo $data;
			
		?></td>
    </tr>
  </table>
</form>
</body>
</html>					